package cn.witsky.cdrService.util;

public class ByteUtil {
	/**
     * 将两个byte数组合并为一个
     * @param data1  要合并的数组1
     * @param data2  要合并的数组2
     * @return 合并后的新数组
     */
    public static byte[] mergeBytes(byte[] data1, byte[] data2) {
        byte[] data3 = new byte[data1.length + data2.length];
        System.arraycopy(data1, 0, data3, 0, data1.length);
        System.arraycopy(data2, 0, data3, data1.length, data2.length);
        return data3;
    }
    
    public static String byteToHex(byte[] bytes) {
    	StringBuilder sb = new StringBuilder();
    	if(bytes!=null) {
            for (byte b : bytes) {
                sb.append(String.format("%02X ", b));
            }
    	}
        return sb.toString();      
    }
}
